<template>
	<view style="padding-top: 20upx;">
		<view class="webkit list mt bb">
			<view class="title">真实姓名</view>
			<input type="text" :value="realname" @input="realnameIpt" class="flex" />
		</view>
		<view class="webkit list mt bb">
			<view class="title">身份证号</view>
			<input type="text" :value="idcard" @input="idcardIpt" class="flex" />
		</view>
		<view style="padding: 0 24upx;">
			<button type="primary" style="background: #7C2548;margin-top: 20upx;" @click="submit">确认修改</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				openid:'',
				realname:'',
				idcard:'',
			};
		},
		onLoad:function(e){
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../../login/login'
					});
				}
			});
		},methods:{
			setAjax(){
				uni.request({
					url: 'https://bhh.ax1319.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.realname&app=1',
					method: 'POST',
					data: {'openid':this.openid},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						console.log(res)
						this.realname = res.data.realname
						this.idcard = res.data.idcard
						uni.hideLoading()
					},
					fail: () => {},
					complete: () => {}
				});
			},
			realnameIpt(e){
				// console.log(e.detail.value)
				this.realname = e.detail.value
			},
			idcardIpt(e){
				this.idcard = e.detail.value
			},
			jump(e){
				uni.navigateTo({
					url: e.currentTarget.dataset.src
				});
			},
			submit(){
				var o = this
				console.log(this.sexnum)
				uni.showLoading()
				uni.request({
					url:'https://bhh.ax1319.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.realname_sub&app=1',
					method: 'POST',
					data: {
						'openid':this.openid,
						'realname': this.realname,
						'idcard': this.idcard,
					},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: res => {
						uni.hideLoading()
						if(res.data.status == 1){
							uni.showToast({
								title: '修改成功',
								icon: 'none'
							});
							setTimeout(() =>{ // 正常返回
									uni.navigateBack();
								},300)
						}else{
							uni.showToast({
								title: res.data.result.message,
								icon:"none"
							});
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>
<style>.list{padding:16upx 24upx;background:#fff;}.angle{position:relative;padding-right:50upx;}.angle:after{content:" ";display:inline-block;-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);height:16upx;width:16upx;border-width:2upx 2upx 0 0;border-color:#b2b2b2;border-style:solid;position:absolute;top:50%;right:30upx;margin-top:-8upx;box-sizing:border-box;}.list .title{width:130upx;line-height:50upx;color:#666;}.list .flex{line-height:50upx;color:#666;padding-left:24upx;}.list .right{color:#999;}.cityp{text-align:left;font-size:28upx;background:transparent;}.cityp:after{display:none;}.bb{position:relative;}.bb:before{content:" ";position:absolute;left:20upx;right:20upx;bottom:-2upx;height:2upx;border-top:1px solid #ebebeb;color:#D9D9D9;-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleY(0.5);-ms-transform:scaleY(0.5);transform:scaleY(0.5);}.layout{background: #7C2548;margin-top:20upx;}</style>